package com.dadi.broadcasttwo;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

/**
 * author: 韦敏敏
 * date: 2019/12/28 0028
 */
public class MainFragment extends Fragment {
    private static final String ARG_PARAM1 = "param1";
    String info = "";
    TextView logger;
    public MainFragment(){
    }
    public static MainFragment newInstance(String param1){
        MainFragment fragment = new MainFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if(getArguments() != null){
            info = getArguments().getString(ARG_PARAM1);
        }
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View myView = inflater.inflate(R.layout.fragment_main, container, false);
        logger = myView.findViewById(R.id.textView2);
        logger.setText(info);
        myView.findViewById(R.id.button).setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                MyJobIntentService.enquework(getContext(), intent);
            }
        });
        return myView;
    }
}
